import Cookies from "js-cookie";

const TokenKey = "token_manager";
const NameKey = "userInfo_manager";

export function getToken() {
  return Cookies.get(TokenKey);
}

export function setToken(token) {
  return Cookies.set(TokenKey, token);
}

export function removeToken() {
  return Cookies.remove(TokenKey);
}

export function getUser() {
  try {
    return JSON.parse(Cookies.get(NameKey));
  } catch (error) {
    return {};
  }
}

export function setUser(name) {
  return Cookies.set(NameKey, name);
}
